package com.itheima.controller;

import com.itheima.domain.mongo.SoundTime;
import com.itheima.service.mongo.SoundTimeServic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/soundTime")
public class SoundTimeController {

    @Autowired
    private SoundTimeServic soundTimeServic;

    //保存更新用户剩余次数
    @PostMapping("/save")
    public void save(SoundTime soundTime) {
        soundTimeServic.save(soundTime);
    }


    //根据id查询用户剩余的次数
    @GetMapping("/findSoundTime")
    public SoundTime findSoundTime(Long userId) {
        return soundTimeServic.findSoundTime(userId);
    }


    //更新语音获取次数
    @GetMapping("/updateTimes")
    public void updateTimes(int count) {
        soundTimeServic.updateTimes(count);
    }
}
